test(visual): fix retry logic silently passing on exhausted retries #2147
+16,863
−16,501
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While working on #2145 I noticed that the retry logic of our visual tests was silently make the suite pass on exhausted retries.
More context
In visual-test-utils.ts, the retry logic was designed to retry non-"Visual diff" errors (like timing issues), but it had a critical flaw: when all 3 retries were exhausted, the do-while loop exited without throwing the error, causing the test to silently pass.
The actual error being thrown was:
Screenshot is not the same width and height as the baseline. Baseline: { width: 227, height: 114 } Screenshot: { width: 256, height: 128 }This error doesn't contain "Visual diff failed.", so it triggered the retry path but never failed the test.
The fix was to track the last error and throw it after the loop exits if we never succeeded.
A lot of the baseline images had to be regenerated because they were silently failing from the time that we changed the width and height atomic classes.